<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
var canBeEqual = function(target, arr) {
    target.sort()
    arr.sort()
    for( var i = 0 ; i<arr.length ; i++ ){
        if( target[i] != arr[i] ){
            return false
        }
    }
    return true
};

var target = [1,2,3,4]
var arr = [2,4,1,3]
console.log(canBeEqual(target, arr))
    </script>
</body>
</html>